package com.niiwoo.civet.trade.enums;

import lombok.Getter;

/**
 * 投资期限
 */
@Getter
public enum InvestDeadlineEnum {
    DAY_BETWEEN_ONE_AND_FIFTEEN((byte) 1, (byte) 2, (byte)1, (byte)15, "1-15天"),
    DAY_BETWEEN_SIXTEEN_AND_THIRTY_ONE((byte) 2, (byte) 2, (byte)16, (byte)31, "16-31天"),
    MONTH_ONE((byte) 3, (byte) 1, (byte)1, (byte)1, "1个月"),
    MONTH_TWO((byte) 4, (byte) 1, (byte)2, (byte)2, "2个月"),
    MONTH_THREE((byte) 5, (byte) 1, (byte)3, (byte)3, "3个月"),
    MONTH_SIX((byte) 6, (byte) 1, (byte)6, (byte)6, "6个月"),
    MONTH_NINE((byte) 7, (byte) 1, (byte)9, (byte)9, "9个月"),
    MONTH_TWELVE((byte) 8, (byte) 1, (byte)12, (byte)12, "12个月"),;
    //序号
    private Byte seq;
    //1月份 2 天数
    private Byte type;
    //最小期限
    private Byte minDeadline;
    //最大期限
    private Byte maxDeadline;
    //描述
    private String msg;


    InvestDeadlineEnum(Byte seq, Byte type, Byte minDeadline, Byte maxDeadline, String msg) {
        this.seq = seq;
        this.maxDeadline = maxDeadline;
        this.minDeadline = minDeadline;
        this.msg = msg;
        this.type = type;
    }

    public static InvestDeadlineEnum enumOf(Byte seq) {
        if (seq == null) {
            throw new IllegalArgumentException("投资期限枚举参数不可空");
        }
        for (InvestDeadlineEnum investDeadlineEnum : values()) {
            if (investDeadlineEnum.getSeq() == seq) {
                return investDeadlineEnum;
            }
        }
        throw new IllegalArgumentException("投资期限枚举参数未知");
    }

    public static InvestDeadlineEnum findEnum(Byte type, Byte minDeadline, Byte maxDeadline) {
        if (type == null || minDeadline == null || maxDeadline == null) {
            throw new IllegalArgumentException("投资期限枚举，参数不可空");
        }
        for (InvestDeadlineEnum investDeadlineEnum : values()) {
            if (investDeadlineEnum.getType() == type && investDeadlineEnum.getMaxDeadline() == maxDeadline && investDeadlineEnum.getMinDeadline() == minDeadline) {
                return investDeadlineEnum;
            }
        }
        return null;
    }

}
